perm filename TALK10.PAL[PNT,HE]1 blob sn#472680 filedate 1979-09-06 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00005 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002
C00004 00003	  Data structures:  Note cells, message buffers
C00007 00004		server,srvsts,pntexecute
C00011 00005	PNTINIT:
C00015 ENDMK
C⊗;

comment ⊗

CODE
;  Special pseudo-ops

SETNAM:	;Interpreter code
	MOV @IPC(R4),INTNAM(R4)
	BMPIPC		;
	CCC		;Clear Condition Code
	RTS PC		;Done
⊗;
;  Data structures:  Note cells, message buffers

;  Notes from 10 to 11:
WAKEUP == 0
LISTEN == 1
WORK   == 2
GOSLEEP == 3

;  Notes from 11 to 10:
ASLEEP == WAKEUP
AWAKE  == 100
LISTNING == 101
WORKING == 102
DONEWORKING == 103
RESTING == 103
GAVEUP == 104

;NOTB10  The notebox from 11 to the 10 (byte address) defined in COMTAB
;NOTB11  The notebox from 10 to the 11 (byte address) defined in COMTAB


DATA
RETSTK==FPPTR
PBUFFSIZ == 1000	;1000 words of pcode
IBUFFSIZ == 1000	;1000 words of integer
FBUFFSIZ == 2000	;1000 words of fp numbers
IIII == .
.==NOTB11
	.WORD 0
PCDBUF:	.WORD 0		;pcode buffer address
INTBUF:	.WORD 0		;integer buffer starting address
FPBUF:	.WORD 0		;floating point buffer starting address
INTPTR:	.WORD 0		;current position of integer pointer
FPPTR:	.WORD 0		;current position of fp buffer
INTSIZ:	.WORD 0		;size of integer buffer
FPSIZ:	.WORD 0		;size of fp buffer
.==IIII

CURNAM:	.WORD 0	;The current ISB for active interpreter.
PNTNAM:	.WORD 0 ;The current ISB for pointy process
ALLIVE:	.WORD 0	;AL interpreter alive if non-zero

STATUS:	.WORD 0	;current status of POINTY in 11

;  Interlock event
; ALDEVT:	.WORD 0

;	server,srvsts,pntexecute

CODE
PNTEXECUTE:
COMMENT	⊗ initializes the buffers and executes the pcode
	⊗

	MOV INTBUF,INTPTR	; beginning of integer buffer
	MOV FPBUF,FPPTR		; beginning of fp buffer
	MOV PNTNAM,R4		; get the right interpreter
	MOV PCDBUF,IPC(R4)	; beginning of pcode buffer
;	MOV #MAININ,R0		; R0←main interpreter PDB
;	MOV PDBR4(R0),R0;	; R0←ISB OF MAIN INTERPRETER
	MOV CURNAM,R0
	MOV ENV(R0),ENV(R4)
	MOV LEV(R0),LEV(R4)
; ***
;	MOV STKBAS(R4),R3	; make sure we have a good stack pointer
; ****				; newly added
	JSR PC,NOTICE		; make sure read arm if necessary
;****
	MOV RF,-(SP)		; Save RF
	MOV SP,RF
	JSR PC,INTRP0		; go do the interpreting
;****				; we will return here only from pdone
	MOV INTPTR,INTSIZ	; compute the integer buffer size
	SUB INTBUF,INTSIZ
	ASR INTSIZ
	MOV FPPTR,FPSIZ		; compute the fp buffer size
	SUB FPBUF,FPSIZ		; by getting difference and dividing by 4
	ASR FPSIZ
	ASR FPSIZ
	RTS PC

;	routine to let 10 know we are awake
DATA
STPDB:	PDBLK	3,100,F	; set up pbd for process to tell 10 we are alive
CODE

SRVSTS:	MOV STATUS,NOTB11
	TST ALDONE
	BEQ 1$
	DISMIS
1$:	SLEEP	#4
	BR SRVSTS

DATA
PNTPDB:	PDBLK 2,150,F	;Makes a process descriptor pointy
NOTVL:	0
CODE

SERVER:	MOV NOTB10,NOTVL ;get value of notb10
	CMP NOTVL,#LISTEN	;is he telling us to listen
	BNE 1$
	MOV #LISTNING,STATUS	;say we are ready to listen
	MOV STATUS,NOTB11
	BR  10$
1$:	CMP NOTVL,#WORK		;is he telling us to work?
	BNE 2$
	MOV #WORKING,STATUS
	MOV STATUS,NOTB11	;we will tell him we are working
; *****				;just added
;	MOV #PNTPDB,SP
;	MOV USKMAX(SP),SP	; make sure we get a good stack pointer
; *****
	JSR PC,PNTEXECUTE	;action
	MOV #DONEWORKING,STATUS ;finished working, tell him that
	MOV STATUS,NOTB11
	BR  10$
2$:	CMP NOTVL,#GOSLEEP	;is he telling us he doesnt need us anymore
	BNE 3$
	MOV #AWAKE,STATUS	;tell him we are available
	MOV STATUS,NOTB11
10$:
3$:	CLR NOTB10
	TST ALDONE		;TEST IF AL PROGRAM FINISHED
	BEQ 4$
	DISMIS			;yes, AL program is done, go away
4$:	SLEEP #500		;rest for a little while
	BR  SERVER		;go find out if there is any more mail
; ******			; code to abort pointy
PNTABT: MOV #GAVEUP,STATUS
	MOV STATUS,NOTB11
	BR  SERVER
PNTINIT:
COMMENT	⊗ initialize every thing ⊗
	MOV #IBUFF,INTBUF	;store starting address as buffer of integers
	MOV #FBUFF,FPBUF	;starting address of FP buffer
	MOV #PBUFF,PCDBUF	;starting address for pcode buffer
	MOV #AWAKE,STATUS	;tell 10 we are awake
	SCHEDU #STPDB,#SRVSTS,#USRDM,#2	;schedule srvsts
; now let us create the ISB for the POINTY process
;	EVMAK			;Create and signal once the AL interlock event.
;	MOV (SP),ALDEVT
;	EVSIG
	CLR NOTB11
	CLR NOTB10
	MOV #1,ALLIVE		;Indicate that the AL interpreter is alive
	MOV #ISBS,R0		;R0 ← Size (in words) of an interpreter status block
	JSR PC,GTFREE		;R0 ← LOC[new interpreter status block]
;	EVMAK			;-(SP) ← event for EVT in this interpreter
;	MOV (SP),EVT(R0)	;new EVT ← event just created.
	MOV R0,-(SP)		;Save LOC[new interpreter status block]
	MOV #INSTSZ,R0		;R0 ← Size needed for an interpreter stack
	JSR PC,GTFREE		;R0 ← LOC[new interpreter stack]
	MOV (SP)+,R1		;R1 ← LOC[new interpreter status block]
	MOV R0,STKBAS(R1)	;Store away new stack base
	ADD #2*INSTSZ,R0	;R0 ← LOC[top of new stack] (INSTSZ is in bytes)
	MOV #PNTPDB,R2		;R2 ← LOC[POINTY process descriptor]
	BIS #UGRSAV+USKSAV,PDBSTA(R2)	;Use saved registers so we can set things up
	MOV R0,PDBR3(R2)	;Store away new interp stack pointer (reg 3)
	MOV R2,PDB(R1)		;Store away LOC[PDB] in new ISB
	MOV R1,PDBR4(R2)	;Store away LOC[ISB] in reg 4 of PDB
	MOV USKMAX(R2),USKP(R2)	;Make sure we have a good stack pointer
	MOV R1,PNTNAM	;This is the current interpreter
	EVWAIT INTEVT		;Interlock sensitive operation, GC needs this
	MOV #NXTINT+ISTBLK,R0	;Link into the interpreter list.
	MOV (R0),NXTINT(R1)
	MOV R1,(R0)
	EVSIG INTEVT		;End of interlock
	SCHEDU R2,#SERVER,#USRDM,#2 ;Cause the new process to be started, suspended
	RTS PC


DATA
IBUFF:	.BLKW	IBUFFSIZ	; integer buffer
FBUFF:	.BLKW	FBUFFSIZ	; real buffer
PBUFF:	.BLKW	PBUFFSIZ	; pcode buffer
CODE